<template>
	<view>
		<web-view v-if="show" :src="testUrl" @message="messageClick" @onPostMessage="onPostMessage"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				testUrl:'',
				show:true,
			}
		},
		onShow() {
			console.log('webview----onshow')
			let date = new Date().getTime()
			this.show = true
			let accessToken = uni.getStorageSync('accessToken')
			let openId = uni.getStorageSync('openId')
			let userId = uni.getStorageSync('userInfo').userId
			this.testUrl = `http://10.10.29.10:8080/?openId=${openId}&userId=${userId}&accessToken=${accessToken}`
			// this.testUrl = 'http://10.10.29.10:8080/'
		},
		onLoad() {
			console.log('webview----onload')
		},
		onHide() {
			console.log('webview----onHide')
			// this.testUrl = ''
			this.show = false
		},
		methods: {
			// 网页向应用 postMessage 时，会在特定时机（后退、组件销毁、分享）触发并收到消息。
			messageClick(){
				console.log('messageClick')
			},
			// 网页向应用实时 postMessage
			onPostMessage(){
				console.log('postMessage')
			},
		}
	}
</script>

<style>

</style>
